home *** CD-ROM | disk | FTP | other *** search
- [totally incomplete and incomprehensible version... oh well better than
- nothing maybe... James]
-
- TEXTURE MAPPING
-
-
- This document contains some ideas on a simple form of linear texture mapping,
- where a walk is made along a line in a source pixelmap to obtain a scanline
- for a texture mapped polygon.
-
- A l' B
- +----.--------+
- | . |
- | . |
- | . |
- | . |
- | . |
- | . |
- |. |
- |. |
- l. |
- | |
- +-------------+
- D C
-
-
- In the above diagram, we walk along ll' picking off pixels to generate
- a texture mapped scan line thru the projection of ABCD.
-
-
- Some ideas for speedups:
-
- Early work does not consider any coherence between pixels on ll', with future
- analysis it might be possible to utilitize some coherence. This might be achieved
- by storing a number of copies of ABCD with either different rotations, different
- pre-zoomed images, and possibly an alternate method of storing the pixmap (such
- as storing a sub-rectangle of 4 adjacent pixels in one word).
-
- One possible speedup... suppose we store 36 pre-rotated copies of each pixmap,
- then it might be possible to cheat by mapping two pixels at once, or maybe up
- to four pixels at once... depending on the size+distortion of the mapped polygon.
- These pixels could be horizontally adjacent... or possibly map a 4x4 square of
- pixels at once. It might be possible to get the blitter to depack these 4x4 squares
- during a chunky2planar conversion.
-
-
- INITIAL IDEAS AT STEPPING ACROSS ll'
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- ;; ideally the simplest approach is
- add.w/l d0,a0 8
- move.b (a0),(a1)+ 8
-
- ;where our image is super scaled in both X and Y directions.
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- ;; D<f> = | x-frac | y-int | y-frac | x-int |
-
- addx.w D<delta-f>,D<f> 4 add delta to step along line
- move.w D<f>,D<tmp> 4 make copy
- and.w D<mask>,D<tmp> 4 mask off integer increment needed
- eor.w D<tmp>,D<f> 4 clear integer overflow from delta-f
- add.w D<tmp>,a0 8 adjust pointer to src
- move.b (a0),(a1)+ 8 pick off source pixel
-
- ;; replace last two with:
- ;; move.b (a0,D<tmp>),(a1)+ 14 saves 2 cycles.
-
- ;Example:
- ; d<f> = | 6 bits | 2 bits | 6 bits | 2 bits |
- ; D<mask> = %000000 11 000000 11
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- ;; Have image Y-scaled 2^n times.
-
- addx.l d0,d1 8
- move.b (a0,d1.w),(a1)+ 14
-
- ; d1 = | x-frac | | y-int+frac | x-int |
-
- ; y-scaling means the fractional part of y-int+frac is effectively
- ; ignored in the pixel look up [or we can have a special filtered zoomed
- ; image... maybe for better looking zoom in/outs
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- ;; as Y=scaled... but use mask to avoid y-scaling. instead we have
- ;; all the different pixmaps interleaved (or sparse pix maps).
-
- addx.l d0,d1 8 add delta
- move.w d1,d2 4
- and.w d3,d2 4 mask of y-fraction
- move.b (a0,d2.w),(a1)+ 14 pick off pixel
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
-
- ;; cube-o-matic [note it has severe register constraints... so subtract
- ;; at least two swaps... to be fair.
-
- moveq #0,d6
- add.w a6,d5
- addx.w d6,d5
-
- swap d5
- move.l a6,d6
- swap d6
- add.w d6,d5
- move.w d5,d6
- swap d5
- move.b d5,d6
-
- move.b 0(a0,d6.w),...
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- add.w dfi,df
- addx.w DI,d6
- move.w dm,dt
- and.w df,dt
- add.w dt,d6
- move.b 0(a0,d6.w),....
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
- ;; Z.b = xint
- ;; X.l = |xf| |y|yf
- add.l delta,X ;8
- addx.b blah,Z ;4
- move.w X,t ;4
- move.b Z,t ;4
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- |x y|<-|x y|+d|x y| 4
- d6 |Y X|<-|Y X|+d|Y X|+carry 4
- move.w dm,dt ; 4
- and.w df,dt ; 4
- eor.w dt,df ; 4
- add.w dt,d6 ; mask off y overflow bit and add it on. 4
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- things to remember:
-
- move.l d0,a0; move.b (a0),(a1)+ is a possibility
- move.l d0,a0 only takes 4 cycles
-
- add Rn,Rn any combo
- addx Dn,Dn data registers only.
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- add.w ddf,df
- move.w dm,dt
- and.w df,dt
- eor.w dt,df
- addx.w dI,dt
- add.l dt,a0
- move.b (a0),...
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
-
- ; d0 = |objectptr| |y|x|
- add.w d1,d2
-
- addx.w DI,d0
- move.w d0,a0 ;4
- move.b (a0),... ;8
-
-
- IDEA -- VERY NASTY -- 68000 only
-
- addx.l d0,d1 ; 8 cycles.... add delta
- move.l d1,a0 ; 4 cycles
- move.b (a0),... ; 8 cycles... top 8 bits masked for free
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- IDEA
- addx.l d0,d1 8
- move.w dm,d2 4
- and.w d1,d2 4
- move.l d2,a0 4
- move.b (a0),...8
-